#include "KdTreeImp.h"


NaiveKdTree::NaiveKdTree(const vector<TCRTMesh*>& Meshes):
	KdTree(Meshes)
{
}

size_t NaiveKdTree::GetMaximumDepth() const
{
	return 10;
}

size_t NaiveKdTree::GetMaximumTrianglePerLeaf() const
{
	return 8;
}

bool NaiveKdTree::StopSplitting(KdTreeNode* pRoot, size_t iLevel)
{
	if (NULL == pRoot 
		|| iLevel + 1 >= GetMaximumDepth() 
		|| pRoot->mTriangleList.size() < GetMaximumTrianglePerLeaf())
	{
		return true;
	}
	else
	{
		return false;
	}
}

bool NaiveKdTree::FindSplitPlane(KdTreeNode* pRoot, size_t iLevel, int& iAxis, float& fPosition)
{
	VEC3 bbCenter = pRoot->mAABB.GetCenter();
	
	iAxis = iLevel % 3;
	fPosition = ((float*)&bbCenter)[iAxis];

	return true;
}
